﻿@model NetSurveillance.WebApp.DataServices.Models.IpSetting

@{
    ViewBag.Title = Resources.MenuResource.SystemSetting_IpSetting;
    Layout = "~/Views/Shared/_SystemConfigLayout.cshtml";
    ViewBag.CurrentMiddleMenu = 5;
    ViewBag.CurrentMainMenu = 5;
}
@section css{
    <style type="text/css">
        fieldset {
            width: 80%;
            margin: 10px auto;
        }
    </style>
}
@using (Html.BeginForm())
{
    @Html.ValidationSummary()
    <fieldset class="inline-fieldset">
        <legend>@ViewBag.Title</legend>
        @Html.Partial("_IpSetting", Model)
    </fieldset>
    <div class="buttonsContain">
        <ul class="config_bottom_btndivs">
            <li>
                <input type="submit" id="btnSaveQuery" value="@Resources.Resource.Button_Apply"/>
            </li>
            <li>
                <input type="reset" id="btnResetChanges" value="@Resources.Resource.Button_ResetChanges"/>
            </li>
        </ul>
    </div>
}
@section javascript
{
    <script type="text/javascript">
        $(function() {
            $('#btnSaveQuery').click(checkSvrIp);
        });

        function checkSvrIp() {
            $.showLoading('正在设置IP，请等待');
            sendChk();
            return false;
        }

        function sendChk() {
            var ipSettingObj = $('form').serializeObject();
            $.ajax({
                url: '@Url.Action("CheckSvrIpSetting")',
                cache: false,
                type: 'post',
                dataType: 'json',
                data: ipSettingObj,
                success: function (result) {
                    if (result.success && !result.expandos) {
                        setTimeout(sendChk, 3000);
                        return;
                    }
                    if (result.success && result.expandos && result.expandos.isValid)
                        $('form').trigger('submit');
                    if (!result.success) {
                        alert(result.message);
                        $.hideLoading();
                    }
                }
            });
        }
    </script>
}